package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.OrderYieldRatioMapperExt;
import com.lzy.product.dtos.OrderYieldRatioDto;
import com.lzy.product.entity.OrderYieldRatio;
import com.lzy.product.service.OrderYieldRatioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class OrderYieldRatioServiceImpl implements OrderYieldRatioService {
    @Autowired
    OrderYieldRatioMapperExt orderYieldRatioMapperExt;

    @Override
    public Boolean createOrderYieldRatio(OrderYieldRatioDto dto) {
        OrderYieldRatio ratio = DozerUtils.map(dto, OrderYieldRatio.class);
        return orderYieldRatioMapperExt.insertSelective(ratio) > 0;
    }

    @Override
    public OrderYieldRatioDto findOrderYieldRatioByOrderId(Long orderId) {
        return orderYieldRatioMapperExt.findOrderYieldRatioByOrderId(orderId);
    }

    @Override
    public Boolean updateOrderYieldRatio(OrderYieldRatioDto dto) {
        OrderYieldRatio ratio = DozerUtils.map(dto, OrderYieldRatio.class);
        return orderYieldRatioMapperExt.updateByPrimaryKeySelective(ratio) > 0;
    }

    @Override
    public List<OrderYieldRatioDto> queryAvailList(String date) {
        return orderYieldRatioMapperExt.queryAvailList(date);
    }

    @Override
    public Integer updateBackedStatus(String date) {
        return orderYieldRatioMapperExt.updateBackedStatus(date);
    }

    @Override
    public Integer updateStartStatus(String date) {
        return orderYieldRatioMapperExt.updateStartStatus(date);
    }
}
